import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  OneToOne,
  JoinColumn,
} from "typeorm";
import { PhotoMetadata } from "./PhotoMetadata.";

@Entity()
export class Photo {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({
    length: 100,
  })
  name: string;

  @Column("text")
  description: string;

  @Column()
  filename: string;

  @Column({
    type: "decimal",
  })
  views: number;

  @Column()
  isPublished: boolean;

  @OneToOne(() => PhotoMetadata, (metadata) => metadata.photo, {
    cascade: true,
    onDelete: "CASCADE",
  })
  metadata: PhotoMetadata;
}
